﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace Inscripcion_materias.DAL
{
    public class DALInscripcion
    {

        string ConnectionString = ConfigurationManager.AppSettings["LocalConnection"].ToString();

        #region Consultar usuario


        public void InscribirMateria(string documento, string estado, string id_grupo, string cod_materia)
        {
            SqlConnection con = new SqlConnection(ConnectionString);
            con.Open();
            SqlCommand cmd = new SqlCommand("InscribirMateria", con);
            cmd.CommandType = CommandType.StoredProcedure;
            
            try
           {
                cmd.Parameters.AddWithValue("@documento", documento);
                cmd.Parameters.AddWithValue("@estado", estado);
                cmd.Parameters.AddWithValue("@id_grupo", id_grupo);
                cmd.Parameters.AddWithValue("@cod_materia", cod_materia);
                cmd.ExecuteNonQuery();
                con.Close();
                
           }
           catch (Exception ex)
           {
             throw ex;
           }
           finally
           {
                cmd.Dispose();
                con.Close();
                con.Dispose();
            }
        }
        #endregion


        #region Eliminar inscripcion


        public void EliminarInscripcion(string id)
        {
            SqlConnection con = new SqlConnection(ConnectionString);
            con.Open();
            SqlCommand cmd = new SqlCommand("EliminarInscripcion", con);
            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                cmd.Parameters.AddWithValue("@id_inscripcion", id);
                cmd.ExecuteNonQuery();
                con.Close();

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                cmd.Dispose();
                con.Close();
                con.Dispose();
            }
        }
        #endregion


      }
}